<template>
  <vxe-modal
    title="查看物资入库详情"
    v-model="dialogVisible"
    v-if="dialogVisible"
    :loading="loading"
    width="70%" showFooter esc-closable show-zoom resize>

    <div style="height: 75vh; overflow-y: auto;">
      <el-card class="box-card" shadow="never" :body-style="{ padding: '10px',backgroundColor: '#bfcdda' }">
        <!-- 物资入库基本信息 -->
        <el-card class="box-card" shadow="hover">
          <div slot="header" class="clearfix">
            <span style="font-size: 16px; color: #1890ff;">物资入库基本信息</span>
          </div>
          <el-descriptions class="margin-top" :column="2" size="medium" border
                           :contentStyle="content_style" :labelStyle="label_style">
            <el-descriptions-item>
              <template slot="label">
                <div class="right-align-label">
                  <i class="el-icon-user"></i>
                  入库方式：
                </div>
              </template>
              {{ wzRkData.rkFs }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <div class="right-align-label">
                  <i class="el-icon-user"></i>
                  入库日期：
                </div>
              </template>
              {{ wzRkData.rkTime }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <div class="right-align-label">
                  <i class="el-icon-user"></i>
                  入库状态：
                </div>
              </template>
              {{ wzRkData.rkZt }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <div class="right-align-label">
                  <i class="el-icon-user"></i>
                  入库人：
                </div>
              </template>
              {{ wzRkData.rkName }}
            </el-descriptions-item>

          </el-descriptions>
        </el-card>
        <br>
        <!-- 入库明细信息 -->
        <el-card class="box-card" shadow="hover" style="min-height: 25vh">
          <div slot="header" class="clearfix">
            <span style="font-size: 16px; color: #1890ff;">入库明细信息</span>
          </div>
          <el-table :header-cell-style="{background:'#d0cece',color:'#000000',fontWeight:'bold'}"
                    height="45vh" :data="wzrkRkmxList" ref="sbdbDbmx">
<!--            <el-table-column type="selection" width="50" align="center"/>-->
            <el-table-column label="序号" align="center" type="index" width="50"/>
            <el-table-column align="center" show-overflow-tooltip label="物资名称" prop="wzName">
              <template slot-scope="scope">
                <el-button
                  type="text"
                  @click="handleButtonClick(scope.row)"
                >
                  <el-link style="font-weight: 600" type="primary">{{ scope.row.wzName }}</el-link>
                </el-button>
              </template>
            </el-table-column>
            <el-table-column align="center" show-overflow-tooltip label="物资单位" prop="wzDw"/>
            <el-table-column align="center" show-overflow-tooltip label="仓库名称" prop="ckName"/>
            <el-table-column align="center" show-overflow-tooltip label="货架名称" prop="hjName"/>
            <el-table-column align="center" show-overflow-tooltip label="分层名称" prop="fcName"/>
            <el-table-column align="center" show-overflow-tooltip label="物资分类" prop="wzFl"/>
            <el-table-column align="center" show-overflow-tooltip label="物资规格" prop="wzGg"/>
            <el-table-column align="center" show-overflow-tooltip label="物资专业" prop="wzZy"/>
            <el-table-column align="center" show-overflow-tooltip label="单价(元)" prop="dj"/>
            <el-table-column align="center" show-overflow-tooltip label="入库数量" prop="rkSl"/>
            <el-table-column align="center" show-overflow-tooltip label="合计金额(元)" prop="hjJe"/>
          </el-table>
        </el-card>
      </el-card>
    </div>
    <div slot="footer" class="dialog-footer dialog-footer-center">
      <el-button @click="dialogVisible=false">关闭</el-button>
    </div>

    <!-- 物资详情 -->
    <WzXq ref="wzXq"/>
  </vxe-modal>
</template>
<script>
import WzXq from "@/views/wzgl/wzxx/components/WzXq.vue";
import {getWzrk} from "@/api/wzgl/wzrk";

export default {
  name: "WzRkXq",
  components: {WzXq},
 //物资入库详情界面
  dicts: ['sbdb_dbzt'],
  data() {
    return {
      wzrkId: null, //物资入库主键ID
      loading: false,
      wzRkData: [], //设备调拨基本信息
      wzrkRkmxList: null, //设备调拨明细表格
      dialogVisible: false,
      content_style: {
        // 解决不对齐的问题
        'width': "400px",
        // 排列第二行
        'word-break': 'break-all',
        // 'background-color': '#f3f7ff'
      },
      label_style: {
        // 解决不对齐的问题
        'width': "250px",
        // 排列第二行
        'word-break': 'break-all',
        'background-color': '#F0F8FF'
      },
    };
  },
  created() {
  },
  methods: {
    handleOpen(row) {
      this.loading = true;
      this.wzrkId = row.wzrkId
      this.dialogVisible = true
      this.getWzRkData()
      setTimeout(() => {
        this.loading = false
      }, 1000)
    },
    //获取详情数据
    getWzRkData() {
      const wzrkId = this.wzrkId
      getWzrk(wzrkId).then(res => {
        this.wzRkData = res.data
        this.wzrkRkmxList = res.data.wzrkRkmxList;
      })
    },
    // 查看物资详情信息
    handleButtonClick(row) {
      this.$refs.wzXq.handleOpen(row);
    },

  }
};
</script>

<style scoped>
.right-align-label {
  text-align: right;
}

/* 定义表头中特定类名的文本居中 */
.el-table .custom-header .cell {
  text-align: center !important;
}
/* header 头部背景 */
/deep/ .el-card__header {
  padding: 3px 7px 3px;
  min-height: 10px;
  background-color: aliceblue;
}
</style>
